/*
 * COM.c
 *
 *  Created on: Jan 20, 2014
 *      Author: adijoshi
 */
//INCLUDES
#include "includes.h"


/*
 * Function: func_COM
 *
 * Inputs:	 Mnemonic, Address_of_destination
 * Outputs:  (None)
 * Condition  Codes:
 * 		Z:  set  if  result  =  0;  cleared  otherwise
 * 		N:  set  if  MSB of result  is set;  cleared  otherwise
 * 		C:  set
 * 		V:  cleared
 */

void func_COM(int mnemonic, unsigned short address_destination)
{
	unsigned short data,result;

	data = read_from_memory(address_destination,DATA);
	result = data ^ 0xFFFF;

	write_in_memory(address_destination,result,DATA);

	update_N_flag(COM,result);
	update_Z_flag(result);
	update_V_flag(COM,data,0,result);
	update_C_flag(COM,data,0,result,0);
}

